function [score,best,labels] = brute_force(g)

    score = zeros(size(g,3),1);
    
    for i = 1:(2^size(g,3))
        y = dec2bin(i-1,size(g,3));
        sum = 0;
        for j = 1:size(g,3)-1
            sum = sum + g(str2num(y(j))+1, str2num(y(j+1))+1, j);
        end
        score(i) = sum;
    end
    
    [~,best] = max(score);
    
    labels = dec2bin(best-1,size(g,3));
    
end